package com.github.nuggets.model.entity;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Optional;

/**
 * @description:
 * @author: wangsj
 * @date: 2022/3/23 2:27 下午
 */
@AllArgsConstructor
@Getter
public enum State {

    RELEASE(1,"发布"),
    CHECKING(2,"审核中"),
    NOT_PASS(3,"未通过"),
    DRAFT(4,"草稿");

    @EnumValue
    private final Integer code;
    private final String label;


    public static Optional<State> getByCode(Integer code){
        for (State value : State.values()) {
            if (value.getCode().equals(code)){
                return Optional.ofNullable(value);
            }
        }
        return Optional.empty();
    }
}
